/*    */ package com.game.majiang.vo;
/*    */ 
/*    */ import com.game.server.db.Parameter;
/*    */ import com.game.server.db.ParameterType;
/*    */ import com.game.server.db.SqlHelper;
import com.game.server.db.SqlHelperwrite;

import java.text.SimpleDateFormat;

/*    */
/*    */ public class CheckCodeVo
/*    */ {
	
			public int verificationCode;
			public long endTime;
	
	
/*    */   public static boolean addCheckCode(int userid, String phone, int checkcode)
/*    */   {
/* 16 */     String cmdText = "insert into checkcode(userid,phone,checkcode,createtime)values(?,?,?,?)";
/* 17 */     Parameter p1 = new Parameter(4, Integer.valueOf(userid), ParameterType.Input);
/* 18 */     Parameter p2 = new Parameter(12, phone, ParameterType.Input);
/* 19 */     Parameter p3 = new Parameter(4, Integer.valueOf(checkcode), ParameterType.Input);

						java.util.Date currentDate = new java.util.Date();
						SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
						String date1 =formatter.format(currentDate);
						Parameter p4 = new Parameter(12, date1, ParameterType.Input);
/* 20 */     Object obj = Integer.valueOf(SqlHelperwrite.execute(cmdText, new Parameter[] { p1, p2, p3 ,p4}));
/* 21 */     if (obj == null) {
/* 22 */       return false;
/*    */     }
/*    */ 
/* 25 */     return true;
/*    */   }
/*    */ 


/*    */   public static boolean checkCode(String phone, int checkcode)
/*    */   {
/* 46 */     String cmdText = "select count(1) from checkcode where phone =? and checkcode=? and createtime > date_sub(sysdate(),interval 600 second)";
/* 47 */     Parameter p1 = new Parameter(12, phone, ParameterType.Input);
/* 48 */     Parameter p2 = new Parameter(4, Integer.valueOf(checkcode), ParameterType.Input);
/* 49 */     Object obj = SqlHelperwrite.execScalar(cmdText, new Parameter[] { p1, p2 });
/* 50 */     if (obj == null || obj.toString().equals("0")) {
/* 51 */       return false;
/*    */     }
/*    */ 
/* 54 */     return true;
/*    */   }
/*    */ 
/*    */   public static int getUserid(String phoneNumber)
/*    */   {
/* 61 */     String cmdText = "select id from users  and phone = ? ";
/* 62 */     Parameter p1 = new Parameter(12, phoneNumber, ParameterType.Input);
/* 63 */     Object obj = SqlHelperwrite.execScalar(cmdText, new Parameter[] { p1 });
/* 64 */     if (obj == null) {
/* 65 */       return -1;
/*    */     }
/*    */ 
/* 68 */     return ((Integer)obj).intValue();
/*    */   }
/*    */ 
/*    */   public static boolean checkCode(int userId, String phoneNumber, int checkcode)
/*    */   {
/* 74 */     String cmdText = "select count(1) from checkcode where userid =? and phone = ? and checkcode=? and createtime > date_sub(sysdate(),interval 120 second)";
/* 75 */     Parameter p1 = new Parameter(4, Integer.valueOf(userId), ParameterType.Input);
/* 76 */     Parameter p2 = new Parameter(12, phoneNumber, ParameterType.Input);
/* 77 */     Parameter p3 = new Parameter(4, Integer.valueOf(checkcode), ParameterType.Input);
/* 78 */     Object obj = SqlHelperwrite.execScalar(cmdText, new Parameter[] { p1, p2, p3 });
/* 79 */     if (((Long)obj).longValue() == 0L) {
/* 80 */       return false;
/*    */     }
/*    */ 
/* 83 */     return true;
/*    */   }
/*    */ 
/*    */   public boolean equals(Object o)
/*    */   {
/* 11 */     if (o == this) return true; if (!(o instanceof CheckCodeVo)) return false; CheckCodeVo other = (CheckCodeVo)o; return other.canEqual(this); } 
/* 11 */   protected boolean canEqual(Object other) { return other instanceof CheckCodeVo; } 
/* 11 */   public int hashCode() { int result = 1; return result; } 
/* 11 */   public String toString() { return "CheckCodeVo()"; }
/*    */ 
/*    */ }
